<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/js/zTree_v3/css/metroStyle/metroStyle.css?v=${FILE_VERSION}" type="text/css">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
			<form class="layui-form" action="${pageContext.request.contextPath}/role/save" style="width:80%" method="post" id="basicform">
				<input type="hidden" id="id" name="id" value="${role.id }"/>

				<c:if test="${MUTI_ORG}">
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label layui-form-required">所属机构</label>
						<c:if test="${userType != 3}">
							<div class="layui-input-inline">
								<input type="hidden" id="orgId" name="orgId" value="${role.orgId}" >
								<input type="text" id="orgName" class="layui-input" readonly="readonly" value="${role.orgName}"
									   lay-verify="required" placeholder="点击选择所属机构" onclick="selectOrg()">
							</div>
							<div class="layui-input-inline">
								<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="selectOrg()">点击选择</button>
							</div>
						</c:if>
						<c:if test="${userType == 3}">
							<div class="layui-input-inline">
								<input type="hidden" name="orgId" value="${role.orgId}" >
								<input type="text" class="layui-input" readonly="readonly" value="${role.orgName}"
									   lay-verify="required" >
							</div>
						</c:if>
					</div>
				</c:if>

				<div class="layui-form-item">
					<label class="layui-form-label layui-form-required">角色名称</label>
					<div class="layui-input-inline">
						<input type="text" name="roleName" id="roleName" lay-verify="required" placeholder="请输入角色名称" class="layui-input" autocomplete="off" value="${role.roleName }">
					</div>
					<div class="layui-form-mid layui-word-aux">角色名称不能为空</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">角色描述</label>
					<div class="layui-input-inline">
						<input type="text" name="roleDesp" placeholder="请输入角色描述" class="layui-input" autocomplete="off" value="${role.roleDesp }">
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
						<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/common/coreInput-2.0.0.js?v=${FILE_VERSION}"></script>
<script>
	layui.config({
		base: getContextPath() + '/static/layuiadmin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['form'], function() {
		var form = layui.form;
		form.on('submit(sub)', function(data){
			return saveOrUpdate($("#id").val(),"/sys/role",data);
		});
	});
	<c:if test="${MUTI_ORG}">
	function selectOrg(){
		var url  = getContextPath() +  "/sys/org/setOrg?queryTop=true";
		layer.open({
			title : "选择机构",
			type: 2,
			area: ['500px', '90%'],
			anim: 2,
			content: [url, 'yes']
		});
	}

	function setOrg(id,name){
		$("#orgId").val(id);
		$("#orgName").val(name);
		layer.closeAll();
	}
	</c:if>
</script>
</body>
</html>